import 'package:flutter/material.dart';
import 'routes/route.dart' as MyRoute;

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        useMaterial3: false,
        primarySwatch: Colors.blue,
      ),
      initialRoute: "/",
      // routes: routes,
      onGenerateRoute: MyRoute.onGenerateRoute,
    );
  }
}

class MyHome extends StatelessWidget {
  const MyHome({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Flutter App"),
      ),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
                onPressed: () {
                  Navigator.pushNamed(context, "/search");
                },
                child: const Text("命名路由")),
            ElevatedButton(
                onPressed: () {
                  Navigator.pushNamed(context, "/prod",
                      arguments: {"aid": "2"});
                },
                child: const Text("命名路由传值")),
          ],
        ),
      ),
    );
  }
}
